home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pas_0593.zip / BIGDRIVE.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-30  |  1KB  |  42 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 244 of 292
  3. From : Bo Bendtsen                         2:231/111.0          15 May 93  11:13
  4. To   : All
  5. Subj : Drive size, free if more than 1 gigabyte
  6. ────────────────────────────────────────────────────────────────────────────────
  7. Hello All!
  8.  
  9. Many people does not think about it, but DOS is limited to report more than
  10. 1 gigabyte. Myself I have a 1.3 giga and a 1.0 giga, and made these routines for
  11. my programs for knowing if the size is more than 1 giga. Using the normal
  12. DiskSize and DiskFree could get you strange result, sometimes it could report
  13. maybe 100MB when it is really 1 giga.
  14.  
  15. If the size og free space is 1 you can assume that the drive is more than 1
  16. gigabyte.}
  17.  
  18. Function DriveSize(d:byte):Longint; { -1 not found, 1=>1 Giga }
  19. Var
  20.   R : Registers;
  21. Begin
  22.   With R Do
  23.   Begin
  24.     ah:=$36; dl:=d; Intr($21,R);
  25.     If AX=$FFFF Then DriveSize:=-1 { Drive not found }
  26.     Else If (DX=$FFFF) or (Longint(ax)*cx*dx=1073725440) Then DriveSize:=1
  27.     Else DriveSize:=Longint(ax)*cx*dx;
  28.   End;
  29. End;
  30.  
  31. Function DriveFree(d:byte):Longint; { -1 not found, 1=>1 Giga }
  32. Var
  33.   R : Registers;
  34. Begin
  35.   With R Do
  36.   Begin
  37.     ah:=$36; dl:=d; Intr($21,R);
  38.     If AX=$FFFF Then DriveFree:=-1 { Drive not found }
  39.     Else If (BX=$FFFF) or (Longint(ax)*bx*cx=1073725440) Then DriveFree:=1
  40.     Else DriveFree:=Longint(ax)*bx*cx;
  41.   End;
  42. End;